package com.erp.app.catalog.itemMaster.delegate;


import java.sql.Connection;
import java.util.ArrayList;

import com.erp.app.catalog.catgroup.criteria.CatalogGroupCriteria;
import com.erp.app.catalog.itemMaster.bizLogic.ItemMasterGroupCommonUtil;
import com.erp.app.catalog.itemMaster.criteria.ItemMasterCriteria;
import com.erp.app.catalog.itemMaster.dao.ItemMasterGroupCommonDao;
import com.erp.framework.exceptions.FindRecordException;
import com.erp.framework.model.criteria.SimpleBaseSrchCriteria;
import com.erp.framework.model.dao.ServiceLocator;
import com.erp.framework.model.vo.SimpleBaseVo;
import com.erp.framework.util.logger.Logger;

public class ItemMasterGroupCommonDelegate {
	private ItemMasterGroupCommonUtil util = new ItemMasterGroupCommonUtil();
	private ItemMasterGroupCommonDao dao = new ItemMasterGroupCommonDao();
	
	public ArrayList findByCriteria(SimpleBaseSrchCriteria criteria, SimpleBaseVo model) throws FindRecordException {
		Connection conn = null;
		ArrayList rsltList = new ArrayList();

		try {
			ServiceLocator srvLocator = ServiceLocator.getInstance();
			conn = srvLocator.getDSDBConnection();
			if (model != null){
				rsltList = (ArrayList) dao.findByCriteria(criteria, model, conn);
			}else{
				rsltList = (ArrayList) dao.findByCriteria(criteria, conn);
			}
		} catch (Exception e) {
			Logger.logExceptions(this, e);
			throw new FindRecordException(e.getMessage());
		} finally {
		try {
				conn.close();
			} catch (Exception e) {
				Logger.logExceptions(this, e);
			}
		}

		return rsltList;
	}
	public ArrayList findByCriteria(SimpleBaseSrchCriteria criteria) throws FindRecordException {
		ArrayList rsltList = new ArrayList();
		rsltList = this.findByCriteria(criteria, null);
		return rsltList;
	}	
}
